#include "queueList.h"

#include <QDebug>

//template <class T>
//int QueueList<T>::size() {
//    return 0;
//}

//template <class T>
//void QueueList<T>::pop ()
//{
//    qDebug() << "pop" << endl;
//}

//QueueList::QueueList() {
//    list = new queueListNode();

//    list->next = NULL;
//    listSize = 0;
//    tail = list;
//}

////bool queueDataCompare(DATATYPE *data1, DATATYPE *data2) {
//////    return data1 == data2 ? true : false;
////    if(data1->fData->stringData.compare(data2->fData->stringData) == 0) {
////        return true;
////    } else {
////        return false;
////    }
////}

//QueueList::~QueueList() {
//    queueListNode *tlist = list, *tnext = list->next;
//    while(tnext != NULL) {
//        tlist->next = tnext->next;
//        delete tnext;
//        tnext = tlist->next;
//    }
//    delete list;
//}

//bool QueueList::Insert(int index, DATATYPE *data) {
//    if(index > listSize - 1) {
//        return false;
//    } else {
//        int i;
//        queueListNode *tlist = list;
//        for(i = 0; i < index; i++) {
//            tlist = tlist->next;
//        }
//        queueListNode *node = new queueListNode();
//        node->data = data;
//        node->next = tlist->next;
//        tlist->next = node;

//        listSize++;
//        return true;
//    }
//}

//bool QueueList::Change(int index, DATATYPE *data) {
//    if(index > listSize - 1) {
//        return false;
//    } else {
//        int i;
//        queueListNode *tlist = list;
//        for(i = 0; i < index; i++) {
//            tlist = tlist->next;
//        }
//        tlist->data = data;
//        return true;
//    }
//}

////bool QueueList::Insert(DATATYPE data, DATATYPE newData) {
////    queueList *tlist = list;
////    while(!queueDataCompare(tlist->data, data) && tlist->next != NULL) {
////        tlist = tlist->next;
////    }

////    if(tlist->next == NULL) {
////        return false;
////    }

////    queueList *tnew = new queueList();
////    tnew->data = newData;
////    tnew->next = tlist->next;
////    tlist->next = tnew;

////    listSize++;
////    return true;
////}

//bool QueueList::InsertToHead(DATATYPE *data) {
//    if(0 == listSize) {
//        list->data = data;
//    } else {
//        queueListNode *newHead = new queueListNode();
//        newHead->data = data;
//        newHead->next = list;
//        list = newHead;
//    }

//    listSize++;
//    return true;
//}
//bool QueueList::InsertToTail(DATATYPE *data) {
//    if(0 == listSize) {
//        list->data = data;
//    } else {
//        queueListNode *newTail = new queueListNode();
//        newTail->data = data;
//        tail->next = newTail;
//        tail = newTail;
//    }

//    listSize++;
//    return true;
//}

//bool QueueList::append(DATATYPE *data) {
//    return InsertToTail(data);
//}

//DATATYPE *QueueList::get(int index) {
//    if(index > listSize - 1) {
//        return nullptr;
//    } else {
//        int i;
//        queueListNode *tlist = list;
//        for(i = 0; i < index; i++) {
//            tlist = tlist->next;
//        }

//        return tlist->data;
//    }
//}

//bool QueueList::Delete(int index) {
//    if(index > listSize - 1) {
//        return false;
//    } else if(index == 0) {
//        // Delete head
//        if(list->next == NULL) { // listSize == 1
//            listSize = 0;
//            return true;
//        } else {
//            queueListNode *tnext = list->next;
//            list->next = tnext->next;
//            // TODO need to delete list->data
//            list->data = tnext->data;
//            delete tnext;
//            if(listSize == 2) {
//                tail = list;
//            }
//            listSize--;
//            return true;
//        }
//    } else {
//        int i;
//        queueListNode *tlist = list, *tnext = list->next;

//        for(i = 1; i < index; i++) {
//            tlist = tlist->next;
//            tnext = tnext->next;
//        }

//        tlist->next = tnext->next;
//        if(tail == tnext) {
//            tail = tlist;
//        }
//        // TODO: need to delete tnext->data
//        delete tnext;

//        listSize--;
//        return true;
//    }

//}

//// This is a set not a list!!
////bool QueueList::QueueListDelete(DATATYPE data) {
////    if(queueDataCompare(list->data, data)) {
////        // Delete head data
////        if(list->next == NULL) {
////            listSize = 0;
////        } else {
////            queueList *tnext = list->next;
////            list->data = tnext->data;
////            list->next = tnext->next;
////            delete tnext;
////            if(listSize == 2) {
////                tail = list;
////            }
////            listSize--;
////        }
////    } else {
////        // Delete normal body
////        queueList *tlist = list, *tnext = list->next;
////        while(tnext != NULL) {
////            if(queueDataCompare(tnext->data, data)) {
////                break;
////            }
////            tlist = tnext;
////            tnext = tnext->next;
////        }
////        if(tnext == NULL) {
////            return false;
////        }

////        tlist->next = tnext->next;
////        if(tail == tnext) {
////            tail = tlist;
////        }
////        delete tnext;

////        listSize--;
////        return true;
////    }
////}

//void QueueList::Print() {
//    queueListNode *tlist = list;
//    while(tlist != NULL) {
////        qDebug() << tlist->data->fData->stringData << endl;
//        itemPrint(tlist);
//        tlist = tlist->next;
//    }
//}

//int QueueList::getSize() {
//    return listSize;
//}


